<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<?php include(DDROOTPATH.'/cache/title/'.$pagetag.'_title.php');?>

<link href="template/<?=MOBAN?>/css/style.css" rel="stylesheet" type="text/css"/>
<link  href="template/<?=MOBAN?>/css/layout.css" rel="stylesheet" type="text/css"/>
<link  href="template/<?=MOBAN?>/css/comm.css" rel="stylesheet" type="text/css"/>
<link  href="template/<?=MOBAN?>/css/mydh.css" rel="stylesheet" type="text/css"/>

<LINK rel=stylesheet type=text/css href="template/<?=MOBAN?>/css/duihuan.css">
<LINK rel=stylesheet type=text/css href="css/colorbox.css" />

<script type="text/javascript" src="template/<?=MOBAN?>/js/jquery-1.3.2.min.js"></script>
<SCRIPT type="text/javascript" src="template/<?=MOBAN?>/js/function.js"></SCRIPT>
<SCRIPT type="text/javascript" src="js/jquery.colorbox.js"></SCRIPT>
<script language="javascript" type="text/javascript">
$(function(){
    $("#dh").click(function(){$('#inline_example1').show();});
});
function checkmobile(str){// 正则判断
    var reg=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}(13)|(18)|(15)[0-9]{9}$)/;
    if(reg.test(str)){
        return true;
    }
    else{
        return false;
    }
}
function checkemail(str){
    reg=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;    
	if(reg.test(str)){    
		return true;
	}
	else{
	    return false;
	}
}
function checkqq(str){
    reg=/^[1-9]\d{4,12}$/;    
	if(reg.test(str)){    
		return true;
	}
	else{
	    return false;
	}
}
function checkForm(){
    var subm=1;
	$('.required').each(function(){
		if($(this).val()==''){
			$(this).focus().addClass('red_border');
		    alert($(this).attr('word'));
			subm=0;
			return false;
		}
    }).blur(function(){
	    if($(this).val()!=''){
		    $(this).removeClass('red_border');
		}
	});
	if(subm==0){
		return false;
	}
	if(subm==1){
		var fangshi=$('#fangshi').val();
	    var spid=$('#spid').val();
	    var tbusername=$('#tbusername').val();
	    var mobile=$('#mobile').val();
		if(!checkmobile(mobile)){
			alert('这不是一个电话号码');
			$('#mobile').focus();
			return false;
		}
	    var email=$('#email').val();
		if(!checkemail(email)){
			alert('这不是一个邮箱');
			$('#email').focus();
			return false;
		}
	    var qq=$('#qq').val();
		if(!checkqq(qq)){
			alert('这不是一个qq号');
			$('#qq').focus();
			return false;
		}
		var address=$('#address').val();
	    var remarks=$('#remarks').val();
	    $.post('ajax.php?fun=save_dh',{'fangshi':fangshi,'spid':spid,'tbusername':tbusername,'mobile':mobile,'email':email,'qq':qq,'address':address,'remarks':remarks,'fresh':Math.random()},function(data){
		    if(data==1){
				alert('提交成功');
				window.location='user/huan.php';
			}
			else{
			    alert(data);
			}
		});
	    return false;
	}
}
</script>
<style>
.red_border{ border:1px solid #F00}
.form_word{float:left;width:60px;height:30px;line-height:30px; font-family:宋体}
.form_input{float:left;width:205px;height:30px;line-height:30px; margin-bottom:10px}
</style>
</head>
<body>
<?php include("head_dh.tpl.php");?>
<div class="dhinfo">
 <div class="line">
 	<div class="left"><a href="index.php">首页</a> &gt; <a href="huan.php">兑换列表</a> &gt; 商品详情</div>
    <div class="right">你会在2周收到物品，虚拟商品将发送到您指定的电子邮箱中！兑换物品免费快递</div>
 </div>
 <div class="line titleFont" style="margin-top:5px;overflow:hidden"><?=$good['name']?></div>
 <div class="line" style="height:330px;margin-top:5px">
 	<div class="picbox"><img src="<?=$good['pic']?>"  width="313" height="313" border="0"/></div>
    <div class="ibox">
     <div class="t" style="margin-top:0px">产品型号：yw12346</div>
     <div class="t">市 场 价：<font style="color:#4ca4cb;text-decoration:line-through"><b><?=$good["jifen"]?></b></font> 元</div>
     <div class="t">优 米 价：<font style="color:#F00;font-size:18px"><b><?=($good["money"]*100)?></b></font> 米&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   <a target="_blank" href="read.php?id=34">怎么获得米？</a>&nbsp;&nbsp;&nbsp;&nbsp;<a target="_blank" href="read.php?id=35">怎么用米兑换？</a></div>
     <div class="t">运&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  费：<span>免运费</span></div>
     <div class="t">送货范围：全国</div>
     <div class="t">库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  存：<?=$good['num']?></div>
     <div class="t">购买数量：无限制 <span>米支付</span></div>
     <?php if($_SESSION['duoduouser']!=NULL){?>
     <div class="t" style="height:37px"><input type="button" id="dh" value=""  class="bnt" onclick="$('#fangshi').val(1);$('.dhlimit').hide();$('#moneylimit').show();$('.needspend').hide();$('#needmoney').show();" /></div>
     <?php }else{?>
     <div class="t" style="height:37px"><input type="button" value=""  class="bnt" onclick="alert('登陆后才可兑换商品！');window.location='user/login.php?url='+encodeURIComponent(window.location.href)" /></div>
     <?php }?>
     <div class="t" style="margin-top:20px">
     	<div class="ico"><img src="template/<?=MOBAN?>/images/ico_add.gif" width="18" height="18" border="0" /></div>
        <div class="ico_txt" style="margin-top:2px"><a>收藏此商品</a></div>
     	<div class="ico" style="margin-left:20px;display:inline"><img src="template/<?=MOBAN?>/images/ico_fx.gif" width="18" height="18" border="0" /></div>
        <div class="ico_txt" style="margin-top:2px">分享给好友</div>
        <div class="ico_txt" style="line-height:0px">
          <!-- Baidu Button BEGIN -->
          <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare" style="margin-top:0px">
              <a class="bds_qzone"></a>
              <a class="bds_tsina"></a>
              <a class="bds_tqq"></a>
              <a class="bds_renren"></a>
              <a class="shareCount"></a>
          </div>
          <script type="text/javascript" id="bdshare_js" data="type=tools" ></script>
          <script type="text/javascript" id="bdshell_js"></script>
          <script type="text/javascript">
              document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=" + new Date().getHours();
          </script>
          <!-- Baidu Button END -->
        </div>
     </div>
    </div>
 </div>
 <div class="line" style="height:auto">
    <ul class="babydetail MarginB10">
      <li id="tab1" class="active"><a onclick="tab(n_spms)" >商品描述</a></li>
      <li id="tab2"><a onclick="tab(n_wxts)">温馨提示</a></li>
    </ul>
    <div class="note" id="n_wxts" style="display:none"><img src="template/<?=MOBAN?>/images/wxts.gif" width="990" height="659"  border="0"  /></div>
    <div class="note" id="n_spms"><?php echo $good['content'];?></div>
 </div>
</div>

<div class="lineclear"></div>
<?php include("footer.tpl.php");?>

<!--现金兑换--------------------------------------------------------------------------------------------------------------------------------------->
<div class="dhframe" id="inline_example1">
   <div class="close" onclick="$('#inline_example1').hide();" style="cursor:pointer"></div>
   <div class="fmbox">
   <form id="form1" name="form1" method="post" action="ajax.php?fun=save_dh" onsubmit="return checkForm()">
   <!--方式-0 现金兑换--><input id="fangshi" name="fangshi" type="hidden" value="" />
   <!--商品ID--><input id="spid" name="spid" type="hidden" value="<?=$good['id']?>" />
     <div class="leftfm">
       <div class="pic"><img  src="<?php echo $good['pic'];?>" width="136" height="136" alt="<?php echo $good['name'];?>" /></div>
       <div class="text"><b style="font-size:15px"><?php echo ($good['money']*100);?></b>米</div>
     </div>
     <div class="line" style="margin-top:15px">
        <div class="t">姓名：</div>
        <div class="fm"><input name='tbusername' type='text' class='edit' word='请填写收货人姓名！' value='<?=$tbusername?>' id='tbusername' maxlength='10' /></div>
     </div>   
     <div class="line" style="margin-top:6px">
        <div class="t">电话：</div>
        <div class="fm"><input name='mobile' type='text' class='edit' word='请填写您的联系电话！' id='mobile' value='<?=$mobile?>' maxlength='20'  /></div>
     </div> 
     <div class="line" style="margin-top:6px">
        <div class="t">地址：</div>
        <div class="fm"><input name='address' type='text' class='edit' word='请填写您的收货地址！' id='address' value='' maxlength='20' /></div>
     </div>
     <div class="line" style="margin-top:6px">
        <div class="t">邮箱：</div>
        <div class="fm"><input name='email' type='text' class='edit' word='请填写邮箱！' id='email' value='<?=$email?>' maxlength='20' /></div>
     </div> 
     <div class="line" style="margin-top:6px">
        <div class="t">Q&nbspQ：</div>
        <div class="fm"><input name='qq' type='text' class='edit' word='请填写联系QQ！' id='qq' value='<?=$qq?>' maxlength='20' /></div>
     </div> 
     <div class="line" style="margin-top:6px;height:65px;">
        <div class="t">说明：</div>
        <div class="fm" style="height:230px"><textarea name="remarks" class="ddinput required" word='请填写附加备注！' id="remarks" style="width:180px;height:60px;line-height:22px;"></textarea></div>
     </div>
     <div class="line" id="moneylimit" style="margin-top:6px;text-align:center">
		<?php if($good['num']<1){?>
        商品库存不足！暂时不能兑换
        <?php }elseif($good['num']>0){?>
          <?php if($dhstate==0){?>
            <?php if(($money*100)<($good['money']*100)) echo "你目前的余额不足以兑换此商品";else echo "<input type='submit' name='Submit' value=' 兑换 ' class='dhbnt' style='float:left;margin-left:40px;display:inline' />";?>
            <?php }elseif($dhstate==1){?>
            <font  color="#c4c5c6">您提交的申请正在处理中</font> <a style="color:#FFF" href="user/huan.php">>>查看详细</a>
        <?php }}?>
     </div> 
     </form>     
   </div>
</div>

<script type="text/javascript">
function tab(obj)
{
  	document.getElementById("n_wxts").style.display="none";
	document.getElementById("n_spms").style.display="none";
	obj.style.display="block";
	if(obj.id=="n_spms")
	{
	  document.getElementById("tab1").className="active";
	  document.getElementById("tab2").className="";
	}
	else
	{
	  document.getElementById("tab1").className="";
	  document.getElementById("tab2").className="active";
	}
}
</script>
</body>
</html>
